export function formatNum(num){
  //单位转化为k（千）或 w（万）,并保留一位小数
  // 1e3为10的三次幂=1000 1e4=10000
  if (num >= 1e3 && num < 1e4) {
    return parseInt(num / 1e3).toFixed(1) + 'K'
  } else if (num >= 1e4) {
    return parseInt(num / 1e4).toFixed(1) + 'w'
  } else {
    return num
  }
}

export function formatTime(value, type = 0){
  var time = new Date(value);
  var year = time.getFullYear();
  var month = time.getMonth() + 1;
  var date = time.getDate();
  var hour = time.getHours();
  var minute = time.getMinutes();
  var second = time.getSeconds();
  month = month < 10 ? "0" + month : month; 
  date = date < 10 ? "0" + date : date; 
  hour = hour < 10 ? "0" + hour : hour; 
  minute = minute < 10 ? "0" + minute : minute; 
  second = second < 10 ? "0" + second : second; 
  var arr = [ 
      year + "-" + month + "-" + date, 
      year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second, 
      year + "年" + month + "月" + date, 
      year + "年" + month + "月" + date + " " + hour + ":" + minute + ":" + second, 
      hour + ":" + minute + ":" + second,
      month + "-" + date
  ] 
  return arr[type]; 

}